import time

from langchain.chains import LLMChain
from langchain_core.prompts import SystemMessagePromptTemplate, HumanMessagePromptTemplate, ChatPromptTemplate

from config.model_config import get_chat_openai_by_biaoshu

model = get_chat_openai_by_biaoshu()


human_template = "{text}"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)
print(human_message_prompt)


chat_prompt = ChatPromptTemplate.from_messages([human_message_prompt])
start_time = time.time()

chain = LLMChain(
    llm = model,
    prompt=chat_prompt,
    # output_parser=CommaSeparatedListOutputParser()
)
res = chain.run(text = '写一篇人工智能的文字，不少于200字')
print(res)

print('-----------------------------------')
answer = chain.invoke({"text": "写一篇人工智能的文字，不少于200字"})['text']
print(answer)

